package com.matt.sooncleaner.wifiscan

import android.graphics.Color
import android.os.Bundle
import com.blankj.utilcode.util.BarUtils
import com.matt.sooncleaner.R
import com.matt.sooncleaner.arch.ArchActivity
import com.matt.sooncleaner.databinding.ActivityWifiScanBinding
import com.trustlook.wifisdk.wifiscan.WifiScanResult

class WifiScanActivity: ArchActivity<ActivityWifiScanBinding>(), WifiScanFragment.OnWifiScanListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val scanFragment = WifiScanFragment()
        scanFragment.setOnWifiScanListener(this)
        supportFragmentManager.beginTransaction()
            .replace(R.id.fragment_container, scanFragment)
            .commitNowAllowingStateLoss()
    }

    override fun onScanFinish(wifiScanResult: WifiScanResult) {
        println("scan finish")
        val resultFragment = WifiScanResultFragment()
        resultFragment.setWifiScanResult(wifiScanResult)
        supportFragmentManager.beginTransaction()
            .replace(R.id.fragment_container, resultFragment)
            .commitNowAllowingStateLoss()
    }
}